package com.service;

import com.dao.WorkingMapper;
import com.entity.Working;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("workingService")
public class WorkingServiceImpl implements WorkingService {
    @Resource
    private WorkingMapper workingMapper;

    public WorkingMapper getWorkingMapper() {
        return workingMapper;
    }

    public void setWorkingMapper(WorkingMapper workingMapper) {
        this.workingMapper = workingMapper;
    }

    @Override
    public int insert(Working working) {
        try {
            return workingMapper.insert(working);
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }

    @Override
    public int update(Working working) {
        try {
            return workingMapper.insert(working);
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }

    @Override
    public int delete(Integer id) {
        try {
            return workingMapper.delete(id);
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }

    @Override
    public List<Working> getAllWorking(Integer currentPage) {
        try {
            return workingMapper.getAllWorking(currentPage);
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }

    @Override
    public Working getWorking(Integer id) {
        try {
            return workingMapper.getWorking(id);
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }

    @Override
    public int count() {
        try {
            return workingMapper.count();
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }

    @Override
    public int getTitleCount(String title) {
        try {
            return workingMapper.getTitleCount(title);
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }
}
